const MyBaseController = require('./MyBaseController');

class UserController extends MyBaseController {


	//登录
	async login() {
		const user = this.ctx.request.body;
		let res = await this.service.user.login(user)
		this.success(res)
	}

	async logout() {
		const user = this.ctx.request.body;
		let res = await this.ctx.app.mysql.update('user_login', user)
		this.success()
	}
	async register() {
		const user = this.ctx.request.body;
		let res = await this.service.user.register(user)
		this.success()
	}

	async update() {
		const user = this.ctx.request.body;
		let res = await this.service.user.update(user)
		this.success(res)
	}
	async getById() {
		let { id } = this.ctx.params
		let res = await this.ctx.app.mysql.get('user', { id: id })
		this.success(res)
	}

	async updatePassword() {
		const user = this.ctx.request.body;
		let res = await this.service.user.updatePassword(user)
		this.success(res)
	}



}

module.exports = UserController;